<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of masterrekening
 *
 * @author miyzan
 */
class potongan extends MY_Controller {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model("potongan_model", "datamodel");
    }

    public function get_rows() {

        $page = ($this->input->post('page', TRUE) ? $this->input->post('page', TRUE) : 1);
        $start = isset($_POST['start']) ? $this->db->escape_str($this->input->post('start', TRUE)) : 0;
        $limit = isset($_POST['limit']) ? $this->db->escape_str($this->input->post('limit', TRUE)) : $this->config->item("length_records");
        $search = isset($_POST['query']) ? $this->db->escape_str($this->input->post('query', TRUE)) : '';

        $result = $this->datamodel->get_rows($search, $start, $limit);
        echo $result;
    }

    public function get_rows_all() {

        $result = $this->datamodel->get_rows_all();
        echo $result;
    }

    public function get_rows_combo() {

        $result = $this->datamodel->get_rows_combo();
        echo $result;
    }

    public function get_rows_entry() {
        $nis = isset($_POST['nis']) ? $this->db->escape_str($this->input->post('nis', TRUE)) : '';
        $th = isset($_POST['idth']) ? $this->db->escape_str($this->input->post('idth', TRUE)) : '';
        $result = $this->datamodel->get_rows_entry($nis, $th);
        echo $result;
    }

    public function update_rows() {
        $opt = isset($_POST['cmd']) ? $this->db->escape_str($this->input->post('cmd', TRUE)) : '';
        $nis = isset($_POST['nis']) ? $this->db->escape_str($this->input->post('nis', TRUE)) : '';
        $th_ajaran_mulai = isset($_POST['th_ajaran_mulai']) ? $this->db->escape_str($this->input->post('th_ajaran_mulai', TRUE)) : '';
        $kd_biaya = isset($_POST['kd_biaya']) ? $this->db->escape_str($this->input->post('kd_biaya', TRUE)) : '';
        $potongan = isset($_POST['mpotongan']) ? $this->db->escape_str($this->input->post('mpotongan', TRUE)) : 0;
        $thbl_mulai = isset($_POST['thbl_mulai']) ? $this->db->escape_str($this->input->post('thbl_mulai', TRUE)) : NULL;
        $thbl_selesai = isset($_POST['thbl_selesai']) ? $this->db->escape_str($this->input->post('thbl_selesai', TRUE)) : NULL;
        $id_potongan = isset($_POST['id_potongan']) ? $this->db->escape_str($this->input->post('id_potongan', TRUE)) : NULL;
        $keterangan = isset($_POST['keterangan']) ? $this->db->escape_str($this->input->post('keterangan', TRUE)) : NULL;
        $id_user = $this->session->userdata('username');

        $result = '';
        $spname = 'sp_potongan';
        $param = array($opt, $id_potongan, $nis, $th_ajaran_mulai, $thbl_mulai, $thbl_selesai, $kd_biaya, $potongan, $keterangan, $id_user);
        $result = $this->datamodel->SP_execData($spname, $param, true);

        echo $result;
    }

    public function delete_row() {
        $opt = isset($_POST['cmd']) ? $this->db->escape_str($this->input->post('cmd', TRUE)) : '';
        $data = isset($_POST['postdata']) ? json_decode($this->input->post('postdata', TRUE)) : array();
        $id_potongan = $data->id_potongan;
        $nis = $data->nis;
        $th_ajaran_mulai = $data->th_ajaran_mulai;
        $thbl_mulai = $data->thbl_mulai;
        $thbl_selesai = $data->thbl_selesai;
        $kd_biaya = $data->kd_biaya;
        $potongan = $data->potongan;
        $keterangan = $data->keterangan;
        $tgl_entri = $data->tgl_entri;
        $id_user = $data->id_user;



        $spname = 'sp_potongan';
        $param = array($opt, $id_potongan, $nis, $th_ajaran_mulai, $thbl_mulai, $thbl_selesai, $kd_biaya, $potongan, $keterangan, $id_user);
        $result = $this->datamodel->SP_execData($spname, $param, true);
        echo $result;
    }

}

?>
